Socket
Socket
Sign inDemoInstall

whatwg-mimetype

Package Overview
Dependencies
Maintainers
6
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

whatwg-mimetype

Parses, serializes, and manipulates MIME types, according to the WHATWG MIME Sniffing Standard


Version published
Weekly downloads
25M
increased by6.18%
Maintainers
6
Weekly downloads
 
Created

What is whatwg-mimetype?

The whatwg-mimetype npm package is a JavaScript implementation of the WHATWG MIME type standard. It allows for parsing, serializing, and manipulating MIME types according to the rules defined by the WHATWG specification.

What are whatwg-mimetype's main functionalities?

Parsing MIME types

This feature allows for the parsing of MIME type strings to create MIMEType objects that can be easily manipulated and queried.

const MIMEType = require('whatwg-mimetype');
const mimeType = new MIMEType('text/html');
console.log(mimeType.toString()); // 'text/html'

Serializing MIME types

This feature enables the conversion of MIMEType objects back into their string representation.

const MIMEType = require('whatwg-mimetype');
const mimeType = new MIMEType('text/html');
console.log(mimeType.toString()); // 'text/html'

Extracting MIME type components

This feature allows for the extraction of the type, subtype, and parameters of a MIME type for further processing or inspection.

const MIMEType = require('whatwg-mimetype');
const mimeType = new MIMEType('text/html; charset=UTF-8');
console.log(mimeType.type); // 'text'
console.log(mimeType.subtype); // 'html'
console.log(mimeType.parameters.get('charset')); // 'UTF-8'

Checking for essence

This feature provides the essence of the MIME type, which is the combination of the type and subtype, excluding any parameters.

const MIMEType = require('whatwg-mimetype');
const mimeType = new MIMEType('text/html; charset=UTF-8');
console.log(mimeType.essence); // 'text/html'

Other packages similar to whatwg-mimetype

Keywords

FAQs

Package last updated on 11 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc